import Cookies from 'js-cookie'

const TokenKey = 'vue_admin_template_token'

export function getToken(user, roles) {
  return Cookies.get(TokenKey, user, roles)
}
export function setToken(token, user, roles) {
  return Cookies.set(TokenKey, token, user, roles)
}
export function removeToken() {
  return Cookies.remove(TokenKey)
}
export function setCookie(key, data) {
  Cookies.set(key, data)
}

export function getCookie(key) {
  const cookie = Cookies.get(key)
  let data = cookie
  if (cookie) {
    data = JSON.parse(cookie)
  }
  return data || ''
}
